<?php
namespace ZHMVC\B\TOOL;

/*
 * 根据表信息生成文件Dao文件
 */
class TableToFile
{
    private $_table;
    private $_file1;
    private $_file2;
    private $_path1;
    private $_path2;
    private $_pre;
    private $_content1;
    // 数据管理类
    private $_content2;
    // 后台文件
    private $_content4;
    // api接口文件
    private $_content3;
    // rpc数据服务类
    // 数据类型，本地还是远程
    private $_rpctype;
    // 如果是远程的话远程地址
    private $__rpcurl;
    // rpc服务站点唯一key
    private $_rpcmainkey;
    // rpc服务站点模块id         
    private $_rpcmoduleid;
    // rpc对接私钥
    private $_rpcprivatekey;

    public function __construct($pre, $tablename, $pathname1, $pathname2, $filename1, $filename2, $modulename, $rpctype = '本地', $rpcurl = '', $rpcmainkey = '',$rpchost='',$rpcprivatekey='',$rpcmoduleid=1)
    {
        $this->_table = $pre . $tablename;
        $this->_file1 = $filename1;
        $this->_file2 = $filename2;
        $this->_path1 = $pathname1;
        $this->_path2 = $pathname2;
        $this->_rpctype = $rpctype;
        $this->_rpcurl = $rpcurl;
        $this->_rpcmainkey = $rpcmainkey;
        $this->_rpcprivatekey = $rpcprivatekey;
        $this->_rpcmoduleid = $rpcmoduleid;
        
        $this->_pre = '';
        
        if ($rpctype == "本地") {
            // 本地数据
        $this->_content1 = '<?php
namespace ' . strtoupper($modulename) . '\\D;
class ' . $this->_file1 . ' extends \\ZHMVC\\D\\DataBase
{
    public function getAllNum($parameter="")
    {
        if(is_array($parameter)==true)
        {
            $bind=array();
            $s="";
            $tempS=parent::parseSql($parameter);
            $bind=$tempS["bind"];
            $s=$tempS["s"];
            
            if($s=="")
            {
                $sql="select count(*) as num from ' . $this->_table . '";
                $data=$this->_db->getOne($sql);
            }
            else
            {
                //去掉第一个逻辑符号
                $s_a=explode(" ", $s);
                $tempS="";
                for($j=1;$j<count($s_a);$j++)
                {
                    $tempS.=$s_a[$j]." ";
                }
            
                $sql="select count(*) as num from ' . $this->_table . ' where ".$tempS;
                $data=$this->_db->getOne($sql,$bind);
            }
        }
        elseif($parameter!="")
        {
            $sql="select count(*) as num from ' . $this->_table . ' where ".$parameter;
            $data=$this->_db->getOne($sql);
        }
        else
        {
            $sql="select count(*) as num from ' . $this->_table . '";
            $data=$this->_db->getOne($sql);
        }
        if(empty($data)==true)
        {
            $data["num"]=0;
        }
        $this->_rows=$this->_db->getRowCount();
        return $data;
    }
            
    public function getAll($parameter="")
    {
        if(is_array($parameter)==true)
        {
            $bind=array();
            $s="";
            $tempS=parent::parseSql($parameter);
            $bind=$tempS["bind"];
            $s=$tempS["s"];
            
            if($s=="")
            {
                $sql="select * from ' . $this->_table . '";
                $datas=$this->_db->getAll($sql);
            }
            else
            {
                $s_a=explode(" ", $s);
                $tempS="";
                for($j=1;$j<count($s_a);$j++)
                {
                    $tempS.=$s_a[$j]." ";
                }
                $sql="select * from ' . $this->_table . ' where ".$tempS;
                $datas=$this->_db->getAll($sql,$bind);
            }
        }
        elseif($parameter!="")
        {
            $sql="select * from ' . $this->_table . ' where ".$parameter."";
            $datas=$this->_db->getAll($sql);
        }
        else
        {
            $sql="select * from ' . $this->_table . '";
            $datas=$this->_db->getAll($sql);
        }
   
        $this->_rows=$this->_db->getRowCount();
        return $datas;
    }
            
    public function getRows()
    {
        return $this->_rows;
    }
            
    public function getPages($limit,$parameter="")
    {
        if(is_array($parameter)==true)
        {
            $bind=array();
            $s="";
            $tempS=parent::parseSql($parameter);
            $bind=$tempS["bind"];
            $s=$tempS["s"];
            if($s=="")
            {
                $sql="select * from ' . $this->_table . ' order by id desc LIMIT ".$limit."";
                $datas=$this->_db->getAll($sql);
            }
            else
            {
                $s_a=explode(" ", $s);
                $tempS="";
                for($j=1;$j<count($s_a);$j++)
                {
                    $tempS.=$s_a[$j]." ";
                }
                $sql="select * from ' . $this->_table . ' where ".$tempS." order by id desc LIMIT ".$limit."";
                $datas=$this->_db->getAll($sql,$bind);
            }
        }
        elseif($parameter!="")
        {
            $sql="select * from ' . $this->_table . ' where ".$parameter." order by id desc LIMIT ".$limit."";
            $datas=$this->_db->getAll($sql);
        }
        else
        {
            $sql="select * from ' . $this->_table . ' order by id desc LIMIT ".$limit."";
            $datas=$this->_db->getAll($sql);
        }
        $this->_rows=$this->_db->getRowCount();
        return $datas;
    }
            
    public function getOne($postid)
    {
        $sql="select * from ' . $this->_table . ' where id=:id";
        $bind=array(":id"=>$postid);
        $data=$this->_db->getOne($sql,$bind);
        $this->_rows=$this->_db->getRowCount();
        return $data;
    }
            
    public function getOne1($parameter="")
    {
        if(is_array($parameter)==true)
        {
            $bind=array();
            $s="";
            $tempS=parent::parseSql($parameter);
            $bind=$tempS["bind"];
            $s=$tempS["s"];
            
            if($s=="")
            {
                $sql="select * from ' . $this->_table . '";
                $datas=$this->_db->getOne($sql);
            }
            else
            {
                $s_a=explode(" ", $s);
                $tempS="";
                for($j=1;$j<count($s_a);$j++)
                {
                    $tempS.=$s_a[$j]." ";
                }
                $sql="select * from ' . $this->_table . ' where ".$tempS;
                $datas=$this->_db->getOne($sql,$bind);
            }
        }
        elseif($parameter!="")
        {
            $sql="select * from ' . $this->_table . ' where ".$parameter."";
            $datas=$this->_db->getOne($sql);
        }
        else
        {
            $sql="select * from ' . $this->_table . '";
            $datas=$this->_db->getOne($sql);
        }
   
        $this->_rows=$this->_db->getRowCount();
        return $datas;
    }
            
    public function add({@InsertB1@})
    {
        $IdWorker = \wantp\Snowflake\IdWorker::getIns();
        $id = $IdWorker->id();
        $sql="insert into ' . $this->_table . ' ({@InsertP@}) values ({@InsertV@})";
        $bind=array({@InsertA@});
        $this->_db->update($sql,$bind);
        $this->_lastid=$id;
        return $this->_lastid;
    }
            
    public function update({@UpdateB1@})
    {
        $sql="update ' . $this->_table . ' set {@UpdateV@} where id=:id";
        $bind=array({@UpdateA@});
        $this->_db->update($sql,$bind);
        return 1;
    }
            
    public function delete($id)
    {
        $sql="delete from ' . $this->_table . ' where id=:id";
        $bind=array(":id"=>$id);
        $this->_db->update($sql,$bind);
        return 1;
    }

    public function addOne()
    {
        $IdWorker = \wantp\Snowflake\IdWorker::getIns();
        $id = $IdWorker->id();
        $sql = "insert into ' . $this->_table . '(`id`) values (:id)";
        //echo $sql;
        $bind = array(":id" => $id);
        $this->_db->update($sql, $bind);
        $this->_lastid = $id;
        return 1;
    }
    
    public function getLastId(){
        return $this->_lastid;
    }
}';
    $this->_content2 = '<?php
namespace ' . strtoupper($modulename) . '\\D;

include(dirname(dirname(dirname(__FILE__)))."/zhconfig/Config.php");
include(dirname(dirname(__FILE__))."/config.php");
include (ZH_PATH . DS . MANAGERFPATH . DS . "top1" . ZH);
?>
<div class="wap-container">
	<nav class="breadcrumb" style="background-color: #fff; padding: 0 24px">
		首页   <a class="btn btn-success radius f-r"
			style="line-height: 1.6em; margin-top: 3px"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
<?php
$action=SafeRequest(getPGC("atcion"),0);
switch ($action) {
    case "save":
        save();
        break;
    case "add":
        add();
        break;
    case "del":
        del();
        break;
    default:
        main();
}
            
function main()
{
    $currentpg =1;
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    }
?>
<article class="Hui-admin-content clearfix">
<div class="panel mt-20">
	<div class="panel-body">
	<div class="clearfix mt-20">
	<table id="zhmvcdata" class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
            <tr class="text-c">
<?php 
$rs10=new \ZHMVC\D\Module();
$sql10="select * from zhmvc_yctable where datatable=\''.$this->_table.'\' and isshow=\'1\' order by xuhao asc";
$datas10=$rs10->getSqlAll($sql10);
$rows10=$rs10->getRowCount();
$lieshu="";
$columns="";
$zhmvclie="";
for($i10=0;$i10<$rows10;$i10++)
{
    $lieshu.=$i10.",";
    $data10=$datas10[$i10];
    $columns.= \'{
                     title: "\'.$data10[\'lietagname\'].\'",
                     name:"\'.$data10[\'liename\'].\'",
                     data:"\'.$data10[\'liename\'].\'",
                     className:"text-c"
                },\';
    $zhmvclie.=$data10["liename"].",";
    echo "<th>".$data10[\'lietagname\']."</th>\n";
}
$lieshu=substr($lieshu, 0, -1);
$zhmvclie=substr($zhmvclie, 0, -1);
?>
        </tr>
    </thead>
    <tbody>
</table>
					</div>
				</div>
			</div>
</article>
</div>
<?php 
include (ZH_PATH . DS . MANAGERFPATH . DS . "foot1" . ZH);
?>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/common/hui/lib/datatables/1.10.21/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/common/hui/lib/datatables/1.10.21/dataTables.select.min.js"></script>
<!-- DataTable buttons -->
<script src="/common/hui/lib/datatables/1.10.21/dataTables.buttons.min.js"></script>
<script src="/common/hui/lib/datatables/1.10.21/dataTables.scroller.min.js"></script>
<script src="/common/hui/lib/datatables/1.10.21/buttons.bootstrap.min.js"></script>
<!-- 右键功能 -->
<script src="/common/hui/lib/datatables/1.10.21/jquery.contextMenu.min.js"></script>
<!-- buttons 打印功能 -->
<script src="/common/hui/lib/datatables/1.10.21/buttons.print.min.js"></script>
<!-- buttons 导出功能 -->
<script src="/common/hui/lib/datatables/1.10.21/buttons.html5.min.js"></script>
<script src="/common/hui/lib/datatables/1.10.21/jszip.min.js"></script>
<script src="/common/hui/lib/datatables/1.10.21/colResizable-1.6.js"></script>
<script src="/common/hui/lib/datatables/1.10.21/dataTables.colReorder.js"></script>
<script type="text/javascript">
var tablelist;
$(function(){
    initTablelist();
});

function initTablelist(){
	
	tablelist =$("#zhmvcdata").DataTable({
    		"language": {
                "url": "/common/hui/lib/datatables/1.10.21/zh.json",//汉化
            },
        	ajax: "'.str_replace("/d/", "", $this->_path1).'/api/'.$this->_file1.'.php?zhmvcdbtype=getdata",
        	searching: true,//关闭搜索框
            processing: true,
            "bProcessing": true,
            paging: false,
            bSort: true,
            ordering: true,
            autoWidth: true,
            stripeClasses: ["table-striped", "even"],// 为奇偶行加上样式，兼容不支持CSS伪类的场合
            destroy: true,
            info:false,
            "loadingRecords": "载入中...",
            "processing": "处理中...",
            dom: "<\'row\'<\'#btn_add.col-md-3\'><\'col-md-3\'><\'col-md-3\'f>r<\'col-md-3 text-right\'B>>t<\'row\'<\'col-md-6\'i>>",
            initComplete: function (settings) {
        		console.log(settings);
        		$("#zhmvcdata").colResizable({liveDrag:true});
			    $("#btn_add").append(\'<div class="clearfix"><span class="f-l"><a href="javascript:;" onclick="add(\\\'添加\\\',\\\'?atcion=add\\\')" class="btn btn-success radius"><i class="Hui-iconfont">&#xe600;</i> 添加</a><a href="javascript:;" onclick="add(\\\'隐藏\\\',\\\'/rkylmanager/admin_column.php?tablename='.$this->_table.'\\\')" class="btn btn-primary radius ml-5"><i class="Hui-iconfont">&#xe600;</i> 隐藏</a></span></div>\');
	     },
	     buttons: [
                "copy", "print", "excel"
            ],
        	columns: [
        		<?php 
                        echo $columns;
                ?>
            ],
            columnDefs: [{
            	"targets": [<?php echo $lieshu;?>], //设置你要给哪一列开启行内编辑
            	fnCreatedCell: function(cell, cellData, rowData, rowIndex, colIndex) {
            		var trow = null;
                   
                    $(cell).contextMenu({
                		menu: [
                        
                        {
                			text: "编辑",
                			callback: function() {
                				var index = layer.open({
                    				type: 2,
                    				title: "编辑",
                    				content: "?atcion=add&postid="+rowData.button.id
                    			});
                    			layer.full(index);
                			}
                		},{
                			text: "删除",
                			callback: function() {
                				layer.confirm("确认要删除吗？",function(index){
                    				$.ajax({
                    					type: "POST",
                    					url: "'.str_replace("/d/", "", $this->_path1).'/api/'.$this->_file1.'.php?zhmvcdbtype=del&data="+rowData.button.id,
                    					dataType: "json",
                    					success: function(data){
                    						$("#zhmvcdata").DataTable().ajax.reload();
                    						layer.msg("已删除!",{icon:1,time:1000});
                    					},
                    					error:function(data) {
                    						console.log(data.msg);
                    					},
                    				});
                    			});
                			}
                		}
                        ]
                	});
                }
            }]
		});
		
	//columns moving
	new $.fn.dataTable.ColReorder( tablelist, {
	 // options 
	} );
}

function tableshuaxin(){
	$("#zhmvcdata").DataTable().ajax.reload();
}


function add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

/*编辑*/
function edit(title,id){
	var index = layer.open({
		type: 2,
		title: title,
		content:"?atcion=add&postid="+id
	});
	layer.full(index);
}

/*删除*/
function del(title,id){
	var that=this;
	layer.confirm(\'确认要删除吗？\',function(index){
		$.ajax({
			type: "POST",
            url:"'.str_replace("/d/", "", $this->_path1).'/api/'.$this->_file1.'.php?zhmvcdbtype=del&data="+id,
			dataType: "json",
			success: function(data){
				$("#zhmvcdata").DataTable().ajax.reload();
				console.log(that);
				layer.msg("已删除!",{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});
	});
}

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
<?php
}
            
function add()
{
    $currentpg =1;
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    }
	$postid=SafeRequest(getPGC("postid"),0);
            
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$data=$rs->getOne($postid);
		$rows=$rs->getRows();
		If($rows!=0)
		{
            $ilistid=$postid;
		    {@Add1@}
		}
		else
		{
            $ilistid="";
		    {@Add2@}
        }
	}
    else
    {
       $ilistid="";
	   {@Add3@}
    }
?>
<div class="panel">
	<div class="panel-body">
         <!-- 表单 -->
            <form name="PForm" id="PForm" method="post" action="?atcion=save&postid=<?php echo $postid; ?>&pg=<?php echo $currentpg;?>" class="form form-horizontal">
            {@AddTd@}
            <div class="row clearfix">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
			</div>
            </form>
          <!-- 表单 -->
          </div>
    	</div>
</div>
<?php 
include (ZH_PATH . DS . MANAGERFPATH . DS . "foot1" . ZH);
?>
<script type="text/javascript">
$(function(){
    $("#name").blur(function(){
        $.getJSON("/api/getPinYin.php?poststr="+$("#name").val(),function(s){
            if(s.code=="0")
            {
                $("#pycode").val(s.data);
            }
            else
            {
                alert(s.message);
            }
        });
    });
});
</script>
</body>
</html>
<?php
}
            
function save()
{
	$postid=SafeRequest(getPGC("postid"),0);
    $currentpg =1;
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    }  
    {@SaveP@}
   
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$data=$rs->update({@SaveB@});
        $ilistid=$postid;
	}
	Else
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$data=$rs->add({@SaveA@});
        $ilistid=$rs->getLastId();
	}
      
?>
</div>
<?php 
include (ZH_PATH . DS . MANAGERFPATH . DS . "foot1" . ZH);
?>
<script type="text/javascript">
function layer_close(){
    //parent.tableshuaxin();
	var index = parent.layer.getFrameIndex(window.name);
    parent.location.reload();
	parent.layer.close(index);
}
layer_close();
</script>
</body>
</html>
<?php
}

            
function del()
{
	$postid=SafeRequest(getPGC("postid"),0);
    $currentpg =1;
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    } 
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$rs->delete($postid);
		//echo "<script>alert(\'更新成功\');window.location.href=\'' . $this->_file2 . '.php?pg=".$currentpg."\';</script>";
	}
    ?>
</div>
<?php 
include (ZH_PATH . DS . MANAGERFPATH . DS . "foot1" . ZH);
?>
<script type="text/javascript">
function layer_close(){
    parent.tableshuaxin();
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
layer_close();
</script>
</body>
</html>
<?php
}
?>
';
            
            $this->_content4='<?php
namespace '.strtoupper($modulename).'\\D;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache"); 
// 制定允许其他域名访问
header("Access-Control-Allow-Origin:*");
// 响应类型
header("Access-Control-Allow-Methods:POST");
// 响应头设置
header("Access-Control-Allow-Headers:x-requested-with, content-type");
ini_set("date.timezone","Asia/Shanghai");
define("SIGNATURE","BRAVEGUO");
define("ISZHMVCAPIBUG",FALSE);
include(dirname(dirname(dirname(__FILE__)))."/zhconfig/Config.php");

if(ISZHMVCAPIBUG==true)
{
    error_reporting(E_ALL);
    ini_set("display_errors", "1");
}
else
{
    error_reporting(0);//E_ALL 0
    ini_set("display_errors", "0");//1 0
}
$token = SafeRequest(getPGC("token"), 0);
$timestamp = SafeRequest(getPGC("timestamp"), 0);
$randomstr = SafeRequest(getPGC("randomstr"), 0);
$zhmvcdbtype = SafeRequest(getPGC("zhmvcdbtype"), 0);
$data = trim(getPGC("data"));

$rs1=new \\'.strtoupper($modulename).'\\D\\' . $this->_file1 . '();
if($zhmvcdbtype=="getdata")
{
    $datas=$rs1->getAll();
    $rows            = $rs1->getRowCount();
    for ($i = 0; $i < $rows; $i++) {
        $datas[$i]["button"]["id"]=$datas[$i]["id"];
    }
    $returnS["data"]=$datas;
}
elseif($zhmvcdbtype=="updateone")
{
    $data=json_decode($data,true);
    $rs1->update({@SaveD@});
}
elseif($zhmvcdbtype=="del")
{
    $data=json_decode($data,true);
    $rs1->delete($data);
}
elseif($zhmvcdbtype=="add")
{
    $rs1->addOne();
}

$returnS["data"]=$datas;

$result = json_encode($returnS);
echo $result;
exit();';
            
            
            // 本地数据
        } else {
            // 远程数据
            $this->_content1 = '<?php
namespace ' . strtoupper($modulename) . '\\D;
class ' . $this->_file1 . '
{
    private $_url;
    private $_mainkey;
    private $_host;
    private $_privatekey;
    private $_moduleid;
    
    private $rs;
    private $_lastid;
    private $_rows;

    public function __construct()
    {
        $this->_id="'.getGUID().'";
        $this->_url="'.$rpcurl.$this->_file1.'rpcserver.php";
        $this->_mainkey="'.$rpcmainkey.'";
        $this->_host="'.$rpchost.'";
        $this->_privatekey="'.$rpcprivatekey.'";
        $this->_moduleid='.$rpcmoduleid.';

        $conn = new \ZHMVC\B\RPC\jsonRPCClient($this->_url, $this->_mainkey, $this->_host, $this->_moduleid, $this->_privatekey, $this->_id);

        if($conn=="error")
        {
            echo "通讯错误";
            exit;
        }
        else
        {
            $this->rs=$conn;
        }
    }
            
    public function getRows()
    {
        return $this->_rows;
    }
          
    public function getLastId(){
        return $this->_lastid;
    }
    
    public function getAllNum($parameter="")
    {
        $data=$this->rs->getAllNum($parameter);
        if(empty($data)==true)
        {
            $data["num"]=0;
        }
        return $data;
    }
    
    public function getAll($parameter="")
    {
        $datas=$this->rs->getAll($parameter);
        $this->_rows=count($datas);
        return $datas;
    }
    
    public function getPages($limit,$parameter="")
    {
        if($parameter=="")
        {
            $datas=$this->rs->getPages($limit);
        }
        else
        {
            $datas=$this->rs->getPages($limit,$parameter);
        }
        $this->_rows=count($datas);
        return $datas;
    }
    
    public function getOne($postid)
    {
        $data=$this->rs->getOne($postid);
        $this->_rows=count($data);
        return $data;
    }
    
    public function add({@InsertB@})
    {
        $parameter=array();
        {@InsertBRPC@}
        $this->_lastid=$this->rs->add($parameter);
        return $this->_lastid;
    }

    public function update({@UpdateB@})
    {
        $parameter=array();
        {@UpdateCRPC@}
        $parameter["id"]=$id;
        $this->rs->update($parameter);
        return 1;
    }
    
    public function delete($id)
    {
        $this->rs->delete($id);
        return 1;
    }
}';
            $this->_content2 = '<?php
namespace ' . strtoupper($modulename) . '\\D;
include(dirname(dirname(dirname(__FILE__)))."/zhconfig/Config.php");
include(dirname(dirname(__FILE__))."/config.php");
$c = new \ZHCONFIG\ZhConfig();
$db_pre = $c->getDbPre();
            
$isp = new \ZHMVC\D\MANAGER\isPermission();
$isper = $isp->getPermission();
$_curlid = $isp->getCUrl();
            
if($isper==1)
{
	$ErrMsg="对不起，你没有访问该页面的权限";
	echo $ErrMsg;
	exit;
}
elseif($isper==0)
{
	$ErrMsg="对不起，地址错误";
	echo $ErrMsg;
	exit;
}
include (ZH_PATH . DS . MANAGERFPATH . DS . "top1" . ZH);
?>
<div class="wap-container">
	<nav class="breadcrumb" style="background-color: #fff; padding: 0 24px">
		模块管理 <a class="btn btn-success radius f-r"
			style="line-height: 1.6em; margin-top: 3px"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
<?php
$action=SafeRequest(getPGC("atcion"),0);
switch ($action) {
    case "save":
        save();
        break;
    case "add":
        add();
        break;
    case "del":
        del();
        break;
    default:
        main();
}
            
function main()
{
$currentpg =1;
if(count($_GET)>0)
{
    if(isset($_GET[\'pg\']))
    {
        $currentpg = $_GET[\'pg\'];
    }
} 
?>
<article class="Hui-admin-content clearfix">
<div class="panel mt-20">
	<div class="panel-body">
		<div class="clearfix">
			<span class="f-l">
				<a href="javascript:;" onClick="location=\'?atcion=add&pg=<?php echo $currentpg;?>\';" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加</a>
			</span>
		</div>
		<div class="clearfix mt-20">
		<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
            <th>Id</th>
            {@MainTh@}
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
<?php
    $conn=new \\'.strtoupper($modulename).'\\D\\' . $this->_file1 . '();
    $rs=$conn->getAllNum();
    $pages = $rs["num"];
    $rs=null;
	If($pages<=0)
	{
		$OutStr="<tr class=\"text-c\">";
		$OutStr=$OutStr."<td colspan=10>&nbsp;<font color=\"red\">暂无内容</font></td>";
		$OutStr=$OutStr."</tr></tbody>";
		echo $OutStr;
	}
	Else
	{
        $pa = new \\ZHMVC\\B\\TOOL\\ShowPages();
		$pa->pvar="pg";
		$pa->set(20,$pages);
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$datas=$conn->getPages($pa->limit());
		$rows=$conn->getRows();
		$rs=null;
		//print_r($datas);
	    for($i=0;$i<$rows;$i++)
	    {
	    	$data=$datas[$i];
  ?>
  <tr class="text-c">
    <td><?php echo $data["id"]; ?></td>
    {@MainTd@}
    <td class="taskOptions"><a href="?atcion=add&postid=<?php echo $data["id"]; ?>&pg=<?php echo $currentpg;?>">编辑</a> | <a href="?atcion=del&postid=<?php echo $data["id"]; ?>&pg=<?php echo $currentpg;?>" onclick="{if(confirm(\'确定删除吗?\')){return true;}return false;}">删除</a></td>
  </tr>
<?php
}
?>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="10">&nbsp;<?php $pa -> output(0); ?></td>
        </tr>
    </tfoot>
<?php
}
?>
</table>
<?php
}
            
function add()
{
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    } 
	$postid=SafeRequest(getPGC("postid"),0);
            
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$data=$rs->getOne($postid);
		$rows=$rs->getRows();
		If($rows!=0)
		{
            $ilistid=$postid;
		    {@Add1@}
		}
		else
		{
            $ilistid="";
		    {@Add2@}
        }
	}
    else
    {
       $ilistid="";
	   {@Add3@}
    }
?>
<div class="panel">
	<div class="panel-body">
        <!-- 表单 -->
            <form name="PForm" id="PForm" method="post" action="?atcion=save&postid=<?php echo $postid; ?>&pg=<?php echo $currentpg;?>" class="form form-horizontal">
            {@AddTd@}
             <div class="row clearfix">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
			</div>
            </form>
          <!-- 表单 -->
        </div>
    </div>
<?php
}
            
function save()
{
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    } 
	$postid=SafeRequest(getPGC("postid"),0);
            
    {@SaveP@}
          
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$data=$rs->update({@SaveB@});
        $ilistid=$postid;
	}
	Else
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$ilistid=$rs->add({@SaveA@});
        //$ilistid=$rs->getLastId();
	}
            
	echo "<script>alert(\'更新成功\');window.location.href=\'' . $this->_file2 . '.php?pg=".$currentpg."\';</script>";
}
            
function del()
{
    if(count($_GET)>0)
    {
        if(isset($_GET[\'pg\']))
        {
            $currentpg = $_GET[\'pg\'];
        }
    } 
	$postid=SafeRequest(getPGC("postid"),0);
	if(($postid!="") && ($postid!="0"))
	{
		$rs=new \\' . strtoupper($modulename) . '\\D\\' . $this->_file1 . '();
		$rs->delete($postid);
		echo "<script>alert(\'更新成功\');window.location.href=\'' . $this->_file2 . '.php?pg=".$currentpg."\';</script>";
	}
    else
    {
        echo "<script>alert(\'参数错误，更新不成功\');window.location.href=\'' . $this->_file2 . '.php?pg=".$currentpg."\';</script>";
    }
}
?>
</div>
<?php 
include (ZH_PATH . DS . MANAGERFPATH . DS . "foot1" . ZH);
?>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>

';
            // 远程数据
        }
    }

    public function parse()
    {
        $st = new \ZHMVC\D\ShowTables();
        $s = $st->getColumns($this->_pre . $this->_table);
        
        //动态加载列
        $zhColumns="";
        $PushLiename="";
        $PushLietag="";
        
        // 插入
        $InsertD = ""; // api插入变量的列表,如$name,$allname,$jxid,$jjjxid
        $UpdateD = ""; // api插入变量的列表,如$name,$allname,$jxid,$jjjxid
        $InsertB1 = ""; // 插入变量的列表,如$name,$allname,$jxid,$jjjxid
        $InsertB = ""; // 插入变量的列表,如$name,$allname,$jxid,$jjjxid
        $InsertP = ""; // 表的字段,如name,allname,jxid,jjjxid
        $InsertV = ""; // 表的字段绑定方法,如name=:name,allname=:allname,jxid=:jxid,jjjxid=:jjjxid
        $InsertA = ""; // 表的字段绑定值,如":name"=>$name,":allname"=>$allname,":jxid"=>$jxid,":jjjxid"=>$jjjxid,":id"=>$id
        $InsertARPC = ''; // 表的字段绑定值,如":name"=>$name,":allname"=>$allname,":jxid"=>$jxid,":jjjxid"=>$jjjxid,":id"=>$id
        $InsertPRPC = ""; // 表的字段,如name,allname,jxid,jjjxid
        $InsertVRPC = ""; // 表的字段绑定方法,如name=:name,allname=:allname,jxid=:jxid,jjjxid=:jjjxid
        $InsertBRPC = "";  //$parameter["name"]=$name
        // 修改
        $UpdateB1 = ''; // 变量的列表,如$name,$allname,$jxid,$jjjxid
        $UpdateB = ''; // 变量的列表,如$name,$allname,$jxid,$jjjxid
        $UpdateV = ""; // 表的字段绑定方法,如name=:name,allname=:allname,jxid=:jxid,jjjxid=:jjjxid
        $UpdateA = ""; // 表的字段绑定值,如":name"=>$name,":allname"=>$allname,":jxid"=>$jxid,":jjjxid"=>$jjjxid,":id"=>$id
        $UpdateARPC = ""; // 表的字段绑定值,如":name"=>$name,":allname"=>$allname,":jxid"=>$jxid,":jjjxid"=>$jjjxid,":id"=>$id  
        $UpdateVRPC = ""; // 表的字段绑定方法,如name=:name,allname=:allname,jxid=:jxid,jjjxid=:jjjxid  
        $UpdateCRPC="";
        // 管理后台
                     // main函数
        $MainTh = '';
        $MainTd = '';
        // add函数
        $Add1 = '';
        $Add2 = '';
        $Add3 = '';
        $AddTd = '';
        // save
        $SaveP = '';
        $SaveB = '$postid,';
        $SaveD = '';
        $SaveA = '';
        for ($i = 0, $imax = count($s); $i < $imax; $i ++) {
            $UpdateD .= '$map[' . $i . '],';
           // if ($s[$i]['field'] != "id") {
                
                if($s[$i]['field'] == "mainkey")
                {
                    $UpdateB1 .= '$' . $s[$i]['field'] . ',';
                    $UpdateB .= '';
                    $UpdateV .= '`' . $s[$i]['field'] . '`=:' . $s[$i]['field'] . ',';
                    $InsertP .= '`' . $s[$i]['field'] . '`,';
                    $InsertV .= ':' . $s[$i]['field'] . ',';
                    $InsertPRPC .= '`' . $s[$i]['field'] . '`,';
                    $InsertVRPC .= ':' . $s[$i]['field'] . ',';
                    $InsertA .= '":' . $s[$i]['field'] . '"=>$' . $s[$i]['field'] . ',';
                    $InsertARPC .= '":' . $s[$i]['field'] . '"=>$mainkey,';
                    $InsertB1.= '$' . $s[$i]['field'] . ',';
                    $InsertB .= '';
                    $InsertBRPC .= ''."\n";
                    $UpdateA .= '":' . $s[$i]['field'] . '"=>$' . $s[$i]['field'] . ',';
                    $UpdateARPC .= '';
                    $UpdateVRPC  .= ''."\n";
                    $UpdateCRPC  .= ''."\n";
                }
                elseif($s[$i]['field'] == "id")
                {
                    $UpdateB1 .= '$' . $s[$i]['field'] . ',';
                    $UpdateB .= '$' . $s[$i]['field'] . ',';
                    $UpdateV .= '';
                    $InsertP .= '`' . $s[$i]['field'] . '`,';
                    $InsertV .= ':' . $s[$i]['field'] . ',';
                    $InsertPRPC .= '`' . $s[$i]['field'] . '`,';
                    $InsertVRPC .= ':' . $s[$i]['field'] . ',';
                    $InsertA .= '":' . $s[$i]['field'] . '"=>$' . $s[$i]['field'] . ',';
                    $InsertARPC .= '":' . $s[$i]['field'] . '"=>$parameter["' . $s[$i]['field'] . '"],';
                    $InsertB1 .= '';
                    $InsertB .= '$' . $s[$i]['field'] . ',';
                    $InsertBRPC .= '$parameter["' . $s[$i]['field'] . '"]=$' . $s[$i]['field'] . ';'."\n";
                    $UpdateA .= '';
                    $UpdateARPC .= '":' . $s[$i]['field'] . '"=>$parameter["' . $s[$i]['field'] . '"],';
                    $UpdateVRPC  .= '`' . $s[$i]['field'] . '`=:' . $s[$i]['field'] . ',';
                    $UpdateCRPC  .= '$parameter["' . $s[$i]['field'] . '"]=$' . $s[$i]['field'] . ';'."\n";
                    
                }
                else
                {
                    $UpdateB1 .= '$' . $s[$i]['field'] . ',';
                    $UpdateB .= '$' . $s[$i]['field'] . ',';
                    $UpdateV .= '`' . $s[$i]['field'] . '`=:' . $s[$i]['field'] . ',';
                    $InsertP .= '`' . $s[$i]['field'] . '`,';
                    $InsertV .= ':' . $s[$i]['field'] . ',';
                    $InsertPRPC .= '`' . $s[$i]['field'] . '`,';
                    $InsertVRPC .= ':' . $s[$i]['field'] . ',';
                    $InsertA .= '":' . $s[$i]['field'] . '"=>$' . $s[$i]['field'] . ',';
                    $InsertARPC .= '":' . $s[$i]['field'] . '"=>$parameter["' . $s[$i]['field'] . '"],';
                    $InsertB1 .= '$' . $s[$i]['field'] . ',';
                    $InsertB .= '$' . $s[$i]['field'] . ',';
                    $InsertBRPC .= '$parameter["' . $s[$i]['field'] . '"]=$' . $s[$i]['field'] . ';'."\n";
                    $UpdateA .= '":' . $s[$i]['field'] . '"=>$' . $s[$i]['field'] . ',';
                    $UpdateARPC .= '":' . $s[$i]['field'] . '"=>$parameter["' . $s[$i]['field'] . '"],';
                    $UpdateVRPC  .= '`' . $s[$i]['field'] . '`=:' . $s[$i]['field'] . ',';
                    $UpdateCRPC  .= '$parameter["' . $s[$i]['field'] . '"]=$' . $s[$i]['field'] . ';'."\n";
                    
                }
                if ($this->_rpctype == "本地") {

                        if($s[$i]['comment']=="")
                        {
                            $MainTh .= '<th>' . $s[$i]['field'] . '</th>
                            ';
                        }
                        else 
                        {
                            $MainTh .= '<th>' . $s[$i]['comment'] . '</th>
                            ';
                        }
                        $MainTd .= '<td><?php echo $data[\'' . $s[$i]['field'] . '\']; ?></td>
                        ';
                        
                }
                else
                {
                    if($s[$i]['field'] == "mainkey")
                    {
                                            
                    }
                    else
                    {
                        if($s[$i]['comment']=="")
                        {
                            $MainTh .= '<th>' . $s[$i]['field'] . '</th>
                            ';
                        }
                        else
                        {
                            $MainTh .= '<th>' . $s[$i]['comment'] . '</th>
                            ';
                        }
                        
                        $MainTd .= '<td><?php echo $data[\'' . $s[$i]['field'] . '\']; ?></td>
                        ';
                    }
                }
                
                
                // ********add函数特别标出来*******
                $Add1 .= '
                    $' . $s[$i]['field'] . '=$data[\'' . $s[$i]['field'] . '\'];
                    ';
                $Add2 .= '
                    $' . $s[$i]['field'] . '=\'\';
                    ';
                $Add3 .= '
                    $' . $s[$i]['field'] . '=\'\';
                    ';
                // 处理各种类型的字段
                // 1判断是否有括号
                if (substr_count($s[$i]['type'], "(") == 0) {
                    $tempE = $s[$i]['type'];
                    // 没有
                    if ($tempE == "text") {
                        if ($this->_rpctype == "本地") {
                            
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {

                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                                else 
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                            }
                        }
                    } elseif ($tempE == "longtext") {
                        if ($this->_rpctype == "本地") {
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            
                            
                            
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {

                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                                else
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                                
                            }
                        }
                    } elseif ($tempE == "mediumtext") {
                        if ($this->_rpctype == "本地") {
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {

                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                            }
                        }
                    } 
                    elseif ($tempE == "decimal") {
                        if ($this->_rpctype == "本地") {
                            
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            
                            
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {
                                
                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                                else
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                                ';
                                }
                                
                                
                            }
                        }
                    }
                    elseif ($tempE == "tinytext") {
                        if ($this->_rpctype == "本地") {
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                            }
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {

                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                                }
                                else
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                                }
                            }
                        }
                    } elseif ($tempE == "double") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                        }
                    } elseif ($tempE == "float") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<textarea id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="textarea" rows="6" placeholder=""><?php echo $' . $s[$i]['field'] . '; ?></textarea>
            					</div>
            				</div>
                            ';
                        }
                    } elseif ($tempE == "datetime") {
                        
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '"  name="' . $s[$i]['field'] . '" readonly class="Wdate input-text datetimepicker-input" onFocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:\'yyyy-MM-dd\'})"  style="width:120px;" value="<?php echo $' . $s[$i]['field'] . '; ?>" >
            					</div>
            				</div>
                             ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '"  name="' . $s[$i]['field'] . '"  readonly class="Wdate input-text datetimepicker-input" onFocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:\'yyyy-MM-dd\'})"  style="width:120px;" value="<?php echo $' . $s[$i]['field'] . '; ?>" >
            					</div>
            				</div>
                             ';
                        }
                        
                        
                    } elseif ($tempE == "date") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '"  name="' . $s[$i]['field'] . '"  readonly class="Wdate input-text datetimepicker-input" onFocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:\'yyyy-MM-dd\'})"  style="width:120px;" value="<?php echo $' . $s[$i]['field'] . '; ?>" >
            					</div>
            				</div>
                             ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '"  name="' . $s[$i]['field'] . '"  readonly class="Wdate input-text datetimepicker-input" onFocus="WdatePicker({isShowClear:false,readOnly:true,dateFmt:\'yyyy-MM-dd\'})"  style="width:120px;" value="<?php echo $' . $s[$i]['field'] . '; ?>" >
            					</div>
            				</div>
                             ';
                        }
                    }
                } else {
                    // 去掉(,获取类型
                    $tempA = explode("(", $s[$i]['type']);
                    $tempB = $tempA[0];
                    $tempC = explode(")", $tempA[1]);
                    $tempD = explode(",", $tempC[0]);
                    if ($tempB == "varchar") {
                        if ($this->_rpctype == "本地") {
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                            }
                        }
                        else
                        {
                            if($s[$i]['field'] == "mainkey")
                            {

                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                                }
                                else
                                {
                                    $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                                }
                            }
                        }
                        
                    } elseif ($tempB == "char") {
                        if ($this->_rpctype == "本地") {
                            if(strtolower($s[$i]['field'])=="id")
                            {
                                $AddTd .= '';
                            }
                            else
                            {
                                if($s[$i]['comment']=="")
                                {
                                    $AddTd .= '
                                <div class="row clearfix">
                					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
                					<div class="form-controls col-xs-8 col-sm-9">
                						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                        value="<?php echo $' . $s[$i]['field'] . '; ?>" />
                					</div>
                				</div>
                                 ';
                                }
                                else
                                {
                                    $AddTd .= '
                                <div class="row clearfix">
                					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
                					<div class="form-controls col-xs-8 col-sm-9">
                						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                        value="<?php echo $' . $s[$i]['field'] . '; ?>" />
                					</div>
                				</div>
                                 ';
                                }
                            }
                        }
                        else
                        {
                            if(strtolower($s[$i]['field'])=="id")
                            {
                                $AddTd .= '';
                            }
                            else
                            {
                                if($s[$i]['field'] == "mainkey")
                                {
    
                                }
                                else
                                {
                                    if($s[$i]['comment']=="")
                                    {
                                        $AddTd .= '
                                <div class="row clearfix">
                					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
                					<div class="form-controls col-xs-8 col-sm-9">
                						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                        value="<?php echo $' . $s[$i]['field'] . '; ?>" />
                					</div>
                				</div>
                                 ';
                                    }
                                    else
                                    {
                                        $AddTd .= '
                                <div class="row clearfix">
                					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
                					<div class="form-controls col-xs-8 col-sm-9">
                						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                        value="<?php echo $' . $s[$i]['field'] . '; ?>" />
                					</div>
                				</div>
                                 ';
                                    }
                                }
                            }
                        }
                        
                    } elseif ($tempB == "decimal") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                    } elseif ($tempB == "tinyint") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                    } elseif ($tempB == "int") {
                        if($s[$i]['comment']=="")
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                        else
                        {
                            $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                        }
                    } elseif ($tempB == "bigint") {
                        if(strtolower($s[$i]['field'])=="id")
                        {
                            $AddTd .= '';
                        }
                        else
                        {
                            if($s[$i]['comment']=="")
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['field'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                            }
                            else
                            {
                                $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $s[$i]['comment'] . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            						<input type="text" id="' . $s[$i]['field'] . '" name="' . $s[$i]['field'] . '" class="input-text" placeholder=""
                                    value="<?php echo $' . $s[$i]['field'] . '; ?>" />
            					</div>
            				</div>
                             ';
                            }
                        }
                    } elseif ($tempB == "enum") {
                        
                        if($s[$i]['comment']=="")
                        {
                            $zhcomment=$s[$i]['field'];
                        }
                        else
                        {
                            $zhcomment=$s[$i]['comment'];
                        }
                        
                        $AddTd .= '
                            <div class="row clearfix">
            					<label class="form-label col-xs-4 col-sm-3">' . $zhcomment . '：</label>
            					<div class="form-controls col-xs-8 col-sm-9">
            					';
                        for ($j = 0, $jmax = count($tempD); $j < $jmax; $j ++) {
                            $atemp = $tempD[$j];
                            $atemp = str_replace("'", "", $atemp);
                            $AddTd .= '
                            <div class="radio-box">
            				  <input name="' . $s[$i]['field'] . '" type="radio" value="' . $atemp . '" id="' . $s[$i]['field'] . '-'.($j+1).'"  
                            <?php
            				if ($' . $s[$i]['field'] . ' == "' . $atemp . '") 
                            { 
                                echo "checked";
                            }
                            ?> 
                            />
            					<label for="' . $s[$i]['field'] . '-'.($j+1).'">' . $atemp . '</label>
            				</div>
                            ';
                        }
                        $AddTd .= '
            					</div>
            				</div>
                          ';
                    }
                }
                // ********add函数特别标出来*******
                
                // save
                if ($this->_rpctype == "本地") {
                    
                    
                    if(strtolower($s[$i]['field'])=="id")
                    {
                        
                    }
                    else
                    {
                        $SaveP .= '$' . $s[$i]['field'] . '=SafeRequest(getPGC("' . $s[$i]['field'] . '"),0);'."\n";
                        $SaveA .= '$' . $s[$i]['field'] . ','; 
                        $SaveB .= '$' . $s[$i]['field'] . ','; 
                    }
                    
                    $SaveD .= '$data["' . $s[$i]['field'] . '"],';
                    
                    if($s[$i]['comment']=="")
                    {
                        $zhColumns.='{
            		              title: "' . $s[$i]['field'] . '",
            		              name:"' . $s[$i]['field'] . '",
            		              data:"' . $s[$i]['field'] . '",
                                  className:"text-c"
            	                 },
                        ';
                        $PushLiename.='liename.push("' . $s[$i]['field'] . '");
                        ';
                        $PushLietag.='lietag.push("' . $s[$i]['field'] . '");
                        ';
                    }
                    else
                    {
                        $zhColumns.='{
            		              title: "' . $s[$i]['comment'] . '",
            		              name:"' . $s[$i]['field'] . '",
            		              data:"' . $s[$i]['field'] . '",
                                  className:"text-c"
            	                 },
                        ';
                        
                        $PushLiename.='liename.push("' . $s[$i]['field'] . '");
                        ';
                        $PushLietag.='lietag.push("' . $s[$i]['comment'] . '");
                        ';
                    }
                    
                    
                }
                else
                {
                    if($s[$i]['field'] == "mainkey")
                    {

                    }
                    else
                    {
                        $SaveP .= '
                    $' . $s[$i]['field'] . '=SafeRequest(getPGC("' . $s[$i]['field'] . '"),0);
                   ';
                        $SaveB .= '$' . $s[$i]['field'] . ',';
                        
                        $SaveA .= '$' . $s[$i]['field'] . ',';  
                    }
                    $SaveD .= '$data["' . $s[$i]['field'] . '"],';
                    $zhColumns.='{
            		              title: "' . $s[$i]['comment'] . '",
            		              name:"' . $s[$i]['field'] . '",
            		              data:"' . $s[$i]['field'] . '",
                                  className:"text-c"
            	                 },
                    ';
                    $PushLiename.='liename.push("' . $s[$i]['field'] . '");
                        ';
                    $PushLietag.='lietag.push("' . $s[$i]['comment'] . '");
                        ';
                }
                
                
                
            //}
        }
        for ($i = 0, $imax = count($s); $i < ($imax-1); $i ++) {
            $InsertD .= '$map[' . $i . '],';
        }
        
        $InsertD = substr($InsertD, 0, strlen($InsertD) - 1);
        $UpdateD = substr($UpdateD, 0, strlen($UpdateD) - 1);
        $zhColumns = substr($zhColumns, 0, strlen($zhColumns) - 1);
        
        
        $InsertB1 = substr($InsertB1, 0, strlen($InsertB1) - 1);
        $InsertB = substr($InsertB, 0, strlen($InsertB) - 1);
        $InsertP = substr($InsertP, 0, strlen($InsertP) - 1);
        $InsertV = substr($InsertV, 0, strlen($InsertV) - 1);
        $InsertA = substr($InsertA, 0, strlen($InsertA) - 1);
        $InsertARPC = substr($InsertARPC, 0, strlen($InsertARPC) - 1);
        $InsertPRPC = substr($InsertPRPC, 0, strlen($InsertPRPC) - 1);
        $InsertVRPC = substr($InsertVRPC, 0, strlen($InsertVRPC) - 1);
        
        $UpdateB1 = substr($UpdateB1, 0, strlen($UpdateB1) - 1);
        $UpdateB = substr($UpdateB, 0, strlen($UpdateB) - 1);
        $UpdateV = substr($UpdateV, 0, strlen($UpdateV) - 1);
        $UpdateVRPC = substr($UpdateVRPC, 0, strlen($UpdateVRPC) - 1);
        $UpdateA .= '":id"=>$id';
        $UpdateARPC .= '":id"=>$parameter["id"]';
        $SaveD = substr($SaveD, 0, strlen($SaveD) - 1);
        $SaveB = substr($SaveB, 0, strlen($SaveB) - 1);
        $SaveA = substr($SaveA, 0, strlen($SaveA) - 1);
        $this->_content1 = str_replace('{@InsertB@}', $InsertB, $this->_content1);
        $this->_content1 = str_replace('{@InsertB1@}', $InsertB1, $this->_content1);
        $this->_content1 = str_replace('{@InsertBRPC@}', $InsertBRPC, $this->_content1);
        $this->_content1 = str_replace('{@UpdateCRPC@}', $InsertBRPC, $this->_content1);
        $this->_content1 = str_replace('{@InsertP@}', $InsertP, $this->_content1);
        $this->_content1 = str_replace('{@InsertV@}', $InsertV, $this->_content1);
        $this->_content1 = str_replace('{@InsertA@}', $InsertA, $this->_content1);
        $this->_content1 = str_replace('{@UpdateB@}', $UpdateB, $this->_content1);
        $this->_content1 = str_replace('{@UpdateB1@}', $UpdateB1, $this->_content1);
        $this->_content1 = str_replace('{@UpdateA@}', $UpdateA, $this->_content1);
        $this->_content1 = str_replace('{@UpdateV@}', $UpdateV, $this->_content1);
        

        $this->_content3 = str_replace('{@InsertPRPC@}', $InsertPRPC, $this->_content3);
        $this->_content3 = str_replace('{@InsertVRPC@}', $InsertVRPC, $this->_content3);
        $this->_content3 = str_replace('{@InsertARPC@}', $InsertARPC, $this->_content3);
        $this->_content3 = str_replace('{@UpdateARPC@}', $UpdateARPC, $this->_content3);
        $this->_content3 = str_replace('{@UpdateVRPC@}', $UpdateVRPC, $this->_content3);
        // print_r($this->content1);
        
        // 后台$this->content2
        /*
         * $MainTh='';
         * $MainTd='';
         * //add函数
         * $Add1='';
         * $AddTd='';
         * //save
         * $SaveP='';
         * $SaveB='$postid,';
         * $saveA='';
         */
        $this->_content2 = str_replace('{@MainTh@}', $MainTh, $this->_content2);
        $this->_content2 = str_replace('{@MainTd@}', $MainTd, $this->_content2);
        $this->_content2 = str_replace('{@Add1@}', $Add1, $this->_content2);
        $this->_content2 = str_replace('{@Add2@}', $Add2, $this->_content2);
        $this->_content2 = str_replace('{@Add3@}', $Add3, $this->_content2);
        $this->_content2 = str_replace('{@AddTd@}', $AddTd, $this->_content2);
        $this->_content2 = str_replace('{@SaveP@}', $SaveP, $this->_content2);
        $this->_content2 = str_replace('{@SaveB@}', $SaveB, $this->_content2);
        $this->_content2 = str_replace('{@SaveA@}', $SaveA, $this->_content2);
        $this->_content2 = str_replace('{@zhColumns@}', $zhColumns, $this->_content2);
        $this->_content2 = str_replace('{@PushLiename@}', $PushLiename, $this->_content2);
        $this->_content2 = str_replace('{@PushLietag@}', $PushLietag, $this->_content2);
      
        
        $this->_content4 = str_replace('{@SaveD@}', $SaveD, $this->_content4);
        $this->_content4 = str_replace('{@InsertD@}', $InsertD, $this->_content4);
        $this->_content4 = str_replace('{@UpdateD@}', $UpdateD, $this->_content4);
    }

    public function saveContent()
    {
        $filepath1 = ZH_PATH . DS . $this->_path1 . $this->_file1 . ZH;
        
        if (file_exists($filepath1)) {} else {
            $fp = fopen($filepath1, 'w');
            fwrite($fp, $this->_content1);
            fclose($fp);
        }
        
        /*
        $filepath3 = ZH_PATH . DS . $this->_path1 . $this->_file1.'rpc' . ZH;
        
        if (file_exists($filepath3)) {} else {
            $fp = fopen($filepath3, 'w');
            fwrite($fp, $this->_content3);
            fclose($fp);
        }
        */
        $filepath2 = ZH_PATH . DS . $this->_path2 . $this->_file2 . ZH;
        if (file_exists($filepath2)) {} else {
            $fp = fopen($filepath2, 'w');
            fwrite($fp, $this->_content2);
            fclose($fp);
        }
        
        $filepath4 = ZH_PATH . DS . str_replace('admin', 'api', $this->_path2) . $this->_file1 . ZH;
        if (file_exists($filepath4)) {} else {
            $fp = fopen($filepath4, 'w');
            fwrite($fp, $this->_content4);
            fclose($fp);
        }
        
    }
}